package com.fosss.band.controller;

import com.alibaba.fastjson.JSON;
import com.fosss.band.exception.MyException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author: fosss
 * Date: 2023/11/25
 * Time: 15:11
 * Description:
 */
@Slf4j
@Api(tags = "测试web功能")
@RestController
@RequestMapping("/hello")
public class HelloController {

    //@Resource
    //private StudentMapper studentMapper;

    @ApiOperation(value = "测试自定义异常")
    @GetMapping("/testE")
    public String testException() {
        log.info("hehehehe");
        log.error("error");
        return "t";
    }

    @ApiOperation(value = "hello world")
    @GetMapping("/test1")
    public String test1() {
        return "hello 你好";
    }

    @ApiOperation(value = "接受url参数")
    @GetMapping("/test2/{name}")
    public String test2(@PathVariable("name") String name) {
        return "test2" + name;
    }

    @GetMapping("/test3")
    public String test3(String name, String password) {
        return name + ":" + password;
    }

    ///**
    // * 测试数据库查询
    // */
    //@GetMapping("/student/selectAll")
    //public String test4() {
    //    List<Student> students = studentMapper.selectAll();
    //    String string = JSON.toJSONString(students);
    //    return string;
    //}
}
